import React from 'react';
import { WeaTop, WeaLeftRightLayout, WeaRightMenu,WeaLocaleProvider } from 'ecCom';
import TaskTypeList from './TaskTypeList';
import TaskListRight from './TaskList';
import { observer, inject } from 'mobx-react';
import './index.less';
const getLabel = WeaLocaleProvider.getLabel;

@inject('edcTaskListStore')
@observer
export default class TaskList extends React.Component {
    componentDidMount() {
        const { edcTaskListStore: store , location: { query: params }} = this.props;
        store.init(params);
    }
    componentWillReceiveProps(nextProps) {
        const { location: { key } , location: { query: params }} = this.props;
        const { location: { key: nextKey , query: nextparams}, edcTaskListStore: store} = nextProps;
        if (key !== nextKey || params !== nextparams) {
            store.init(nextparams);
        }
    }
    render() {
        const { edcTaskListStore: store, location: { query: params } } = this.props;
        let title = "";
        if(params && params.taskname) {
            title = params.taskname;
        }
        const menu = [{
            key: '1',
            icon: <i className='icon-coms-search' />,
            content: getLabel(388113,'搜索'),
            onClick: store.search,
        },]
        return (
            <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@qpa4yg`} datas={menu} >
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@pptv82`}
                    title={title ? title : getLabel('502834','我的填报任务')}
                    iconBgcolor="#1a57a0"
                    icon={<i className="icon-coms02-Data-center" />}
                    showDropIcon={true}
                    dropMenuDatas={menu}
                    loading={store.tableStore.loading}
                >
                    <WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@7m3i7d`}
                        leftWidth={300}
                        leftCom={<TaskTypeList ecId={`${this && this.props && this.props.ecId || ''}_TaskTypeList@7qfdxc`} store={store} params={params}/>}
                    >
                        <TaskListRight ecId={`${this && this.props && this.props.ecId || ''}_TaskListRight@8nhg23`} store={store} params={params} />
                    </WeaLeftRightLayout>
                </WeaTop>
            </WeaRightMenu>
        )
    }
}